<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>记账簿 - 统计</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="page-header">
				<h1 align="center">
					<strong>小刘记账 统计</strong>
					</h2>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-8">
				<ul class="nav nav-pills">
					<li><a href="index.html">首页</a></li>
					<li><a href="add2.html"><strong>新加收入</strong></a></li>
					<li><a href="add1.html"><strong>新加支出</strong></a></li>
					<li><a href="#"><strong>用户：</strong><span id="text3"></span></a>
					</li>
					<li class="active"><a href="tongji.html"><strong>统计</strong></a>
					</li>
					<li><a href="query.html"><strong>查询</strong></a></li>
					<li><a href="xiangqing.html"><strong>详情</strong></a></li>
				</ul>
			</div>
		</div>
	</div>

	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<hr />
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-warning">
					<div class="panel-heading">收入统计</div>
					<div class="panel-body" id="list1"></div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-warning">
					<div class="panel-heading">支出统计</div>
					<div class="panel-body" id="list2"></div>
				</div>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-6">
				<div class="panel panel-primary">
					<div class="panel-heading">当月收入总和</div>
					<strong>总收入</strong>
					<div class="panel-body" id="text6"></div>
				</div>
			</div>
			<div class="col-md-6">
				<div class="panel panel-primary">
					<div class="panel-heading">当月支出总和</div>
					<strong>总支出</strong>
					<div class="panel-body" id="text7"></div>
				</div>
			</div>
		</div>
	</div>

	<div class="container">
		<div class="row">
			<div class="col-md-6" id="chart">
				<p class="text-center">
					<br />
				<hr />
				<strong>支出统计</strong>
				<svg style="height: 480px; width: 100%"></svg>
				<br />
				</p>
			</div>
			<div class="col-md-6" id="chart1">
				<p class="text-center">
					<br />
				<hr />
				<strong>收入统计</strong>
				<svg style="height: 480px; width: 100%"></svg>
				<br />
				</p>
			</div>

		</div>
	</div>
	<script id="template" type="text/x-handlebars-template">
{{#each item}}
<div class="panel panel-default col-md-3 ">
   <div class="panel-body">
     <dl>
<dt>类别</dt><dd>{{kind}}</dd>
<dt>总和</dt><dd>{{shou}}</dd>
<dt>平均</dt><dd>{{p1}}</dd>
     </dl>
   </div>
 </div>
{{/each}}
</script>

	<script id="template2" type="text/x-handlebars-template2">
{{#each item}}
<div class="panel panel-default col-md-3 ">
   <div class="panel-body">
     <dl>
<dt>类别</dt><dd>{{kind}}</dd>
<dt>总和</dt><dd>{{zhi}}</dd>
<dt>平均</dt><dd>{{p2}}</dd>
     </dl>
   </div>
 </div>
{{/each}}
</script>

	<script type="text/javascript">
		$(function() {
			$.getJSON('queryuser.action', function(res) {
				console.log(res);
				$('#text3').text(res.nickname);
			});
			$.getJSON('pin5.action', function(res) {
				console.log(res);
				$('#text6').text(res.sr);
			});
			$.getJSON('pin6.action', function(res) {
				console.log(res);
				$('#text7').text(res.zc);
			});
			$.getJSON('queryg.action', function(res) {
				console.log(res);
				var data = {
					'item' : res
				};
				var t = Handlebars.compile($('#template').html());
				$('#list1').html(t(data));
			});
			$.getJSON('queryg.action', function(res) {
				console.log(res);
				var data = {
					'item' : res
				};
				var t = Handlebars.compile($('#template2').html());
				$('#list2').html(t(data));
			});

			$.getJSON('queryg.action', function(res) {
				nv.addGraph(function() {
					var chart = nv.models.pieChart().x(function(d) {
						return d.kind
					}).y(function(d) {
						return d.zhi
					}).showLabels(true).labelType('percent');
					d3.select("#chart svg").datum(res).transition().duration(
							350).call(chart);
					return chart;
				})
			});
			$.getJSON('queryg.action', function(res) {
				nv.addGraph(function() {
					var chart1 = nv.models.pieChart().x(function(d) {
						return d.kind
					}).y(function(d) {
						return d.shou
					}).showLabels(true).labelType('percent');
					d3.select("#chart1 svg").datum(res).transition().duration(
							350).call(chart1);
					return chart1;
				})
			});

		});
	</script>
	<script type="text/javascript" src="libs/handlebars.min.js">
		
	</script>
	<script type="text/javascript" src="libs/d3.v3.min.js">
		
	</script>
	<script type="text/javascript" src="libs/nv.d3.min.js">
		
	</script>
	<script type="text/javascript" src="libs/nv.d3.min.css">
		
	</script>
</body>
</html>

